package models

import (
	beego "github.com/beego/beego/v2/adapter"
	"github.com/beego/beego/v2/client/orm"
)

//初始化
func init() {
	orm.RegisterModel(
		new(BackendUser),
		new(Department),
		new(Resource),
		new(Role),
		new(RoleResourceRel),
		new(RoleBackendUserRel),
		new(Options),
		new(Archives),
		new(Optometry),
		new(OptometryData),
		new(Schools),
		new(ErpBrand),
		new(ErpWarehouse),
		new(ErpClass),
		new(ErpProducts),
		new(ErpProductsSnd),
		new(ErpProductsPrice),
		new(ErpEntry),
		new(ErpEntryData),
		new(ErpInventory),
		new(EquipmentData),
		new(Retails),
		new(RetailsData),
		new(RetailsCustom),
		new(Refunds),
		new(RefundsData),
		new(RetailsLog),
		new(ErpStocks),
		new(StocksData),
		new(Allocation),
		new(AllocationData),
		new(AllocationMiddle),
		new(Interrogations),
		new(SmsSendLog),
		new(Followup),
		new(Inspects),
		new(InspectsPriceLog),
		new(InspectsSum),
		new(ErpSuppliers),
		new(WechatSetings),
		new(WechatMenu),
		new(WechatMessage),
		new(WechatFollows),
		new(ErpProductsAttribute),
		new(ErpEntryMiddle),
		new(ErpAcceptance),
		new(ErpAcceptanceData),
		new(ErpFlowing),
		new(ErpFlowingData),
		new(ErpEntryreturn),
		new(ErpEntryreturnData),
		new(ErpEntryreturnMiddle),
		new(ErpBadreport),
		new(ErpBadreportData),
		new(ErpCuring),
		new(ErpCuringData),
		new(Gsparchives),
		new(DoGuahao),
		new(DoDiagnosis),
		new(DoDiagnosisOften),
		new(DoProjectOften),
		new(DoDoctorOrder),
		new(DoDoctorOrderNumber),
		new(SaCollectfeesDoctororder),
		new(SaCollectfeesDoctororderMiddle),
		new(SaCollectfeesDispensing))
}

//下面是统一的表名管理
func TableName(name string) string {
	prefix := beego.AppConfig.String("db_dt_prefix")
	return prefix + name
}

//获取 BackendUser 对应的表名称
func BackendUserTBName() string {
	return TableName("backend_user")
}

//获取 Resource 对应的表名称
func ResourceTBName() string {
	return TableName("resource")
}

//获取 Role 对应的表名称
func RoleTBName() string {
	return TableName("role")
}

//角色与资源多对多关系表
func RoleResourceRelTBName() string {
	return TableName("role_resource_rel")
}

//角色与用户多对多关系表
func RoleBackendUserRelTBName() string {
	return TableName("role_backenduser_rel")
}
